1. Navigating along a graph path

prefix : <http://laurenzi.ch#>
SELECT ?x WHERE 
{:Amalia :hasChild/:hasChild/:likesMovie  ?x}
(what does Amalia's grandchild like?)

------------------------------------------------------------------------
2. Navigating a path of unknown length
prefix : <http://laurenzi.ch#>
SELECT ?x WHERE 
{:Amalia 	:hasChild+/:likesMovie 	?x}
(what do all Amalia's descendants like?)

-----------------------------------------------------------------------
3. Navigating a path in reverse:
prefix : <http://laurenzi.ch#>
SELECT ?x WHERE 
{?x ^:likesMovie/^:hasChild/^:hasChild :Amalia}

-----------------------------------------------------------------------

4. Step-wise navigation of a path (it can retrieve intermediate nodes and edges)
prefix : <http://laurenzi.ch#>
SELECT ?a ?b ?c WHERE 
{:Amalia :hasChild ?a.
?a :hasChild ?b.
?b  :likesMovie ?c}
*the decomposition into statements complies with the Turtle syntax

-----------------------------------------------------------------------

5. Retrieving potentially missing information (give me all parents and, IF AVAILABLE, their work place)
prefix : <http://laurenzi.ch#>
SELECT ?a ?c WHERE
{?a  :hasChild  ?b.
OPTIONAL 
	{?a   :worksAt  ?c}}
-----------------------------------------------------------------------

6. What relationship exists between Grazia and ITEHighSchool?
prefix : <http://laurenzi.ch#>
SELECT     ?rel WHERE 
{:Grazia 	?rel 	:ITEHighSchool}

-----------------------------------------------------------------------

8. Who is the director of the movie that Amalia's grandchild likes? 
(To make this query work we would need the prefix «dbr» as a prefix for :Terminator in our data set. 
But our Dataset only has :Terminator)

prefix : <http://laurenzi.ch#>
prefix dbr: <http://dbpedia.org/resource/>
prefix dbo: <http://dbpedia.org/ontology/>


SELECT ?x WHERE 
{
:Amalia :hasChild/:hasChild/:likes  ?film.  #query on the local graph

SERVICE <https://dbpedia.org/sparql> {?film dbo:director ?x}   #query jumps to public graph
}
-----------
prefix : <http://laurenzi.ch#>
prefix dbr: <http://dbpedia.org/resource/>
prefix dbo: <http://dbpedia.org/ontology/>


SELECT ?x WHERE 
{
:Amalia :hasChild/:hasChild/:likes  ?film.  #query on the local graph

SERVICE <https://dbpedia.org/sparql> {?film dbo:director ?x}   #query jumps to public graph
}


-----------------------------------------------------------------------

9. Extracting a subgraph (Extract the network of child relationships)
prefix : <http://laurenzi.ch#>
CONSTRUCT WHERE 
{?x :hasChild ?y}

---------------------------------------------------------------------

10. Generates the statement "X hasRelatives in Y" for 
any X who has descendants living in Y:

prefix : <http://laurenzi.ch#>
CONSTRUCT {?x :hasRelativesIn ?y}
WHERE {?x :hasChild+/:livesIn ?y}

---------------------------------------------------------------------
11. if X likes Terminator, she is a Cinephile:

PREFIX dbr: <http://dbpedia.org/resource/>
prefix : <http://laurenzi.ch#>
CONSTRUCT {?x a :Cinephile} 
WHERE {?x :likes dbr:The_Terminator}

--------------------------------------------------------------------

12. If X likes movies, she is a Cinephile:
prefix : <http://laurenzi.ch#>
CONSTRUCT {?x a :Cinephile} 
WHERE {?x :likes/a :Movie}

in order to make this rule work, you first have to have the following statment in the dataspace: 
dbr:The_Terminator a :Movie;

